﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace Portal.AjaxPage
{
    public partial class GetImagePage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["src"])) 
            {
                //获取文件路径
                string imgSrc = Request["src"].ToString();

                //输出图片
                System.IO.FileStream fs = new System.IO.FileStream(imgSrc, FileMode.Open, FileAccess.Read);
                byte[] fileByte = new byte[fs.Length];
                fs.Read(fileByte, 0, (int)fs.Length);
                Response.AddHeader("Content-Disposition", "filename=" + imgSrc.Substring(imgSrc.LastIndexOf("\\") + 1));
                Response.BinaryWrite(fileByte);
                Response.Flush();
                Response.End();
            }
        }
    }
}